תוכנה 1 סמסטר א' תשע"א

Size: px
Start display at page:

Download "תוכנה 1 סמסטר א' תשע"א"

Transcription

1 General Tips on Programming תוכנה 1 סמסטר א' תשע"א תרגול מס' 6 מנשקים, דיאגרמות וביטים * רובי בוים ומתי שמרת Write your code modularly top-down approach Compile + test functionality on the fly Start with an empty program/classes Add content gradually and keep testing If something goes wrong, probably the bug is in the latest change * לא בהכרח בסדר הזה General Tips on Programming Even More Tips Use the Debugger to follow your execution flow and find what went wrong Understanding is good but not enough you must practice! Based on a true story: Do not send us code Do not send us s saying the code you gave us does not work, before you make sure the original given code is problematic When you ask questions be as specific as you can, give as much information about the problem and your trials as possible Even More Tips Late submissions / appeals on homework grades? Please contact the graders odedelba@post.tau.ac.il המערכת הבנקאית נתאר את מערכת התוכנה שלנו בעזרת דיאגרמות דיאגרמות סטטיות: תיאור היחסים בין המחלקות השונות במערכת דיאגרמות דינאמיות: תיאור ההתנהגות של המערכת בזמן ריצה מצב האוביקטים תיאור של תרחיש 6 1

2 Class Diagram המחלקה Customer Customer Account public Account(Customer customer, long id) public withdraw(double amount) public (double amount) public transferto(double amount, Account otheraccount) public double getbalance() public Customer getowner() public double getnumber() Aggregation (has-a) public Customer(String name, String id) * public String getname() public String getid() main Association 7 public class Customer public Customer(String name, String id) this.name = name; this.id = id; public String getname() return name; public String getid() return id; private String name; private String id; 8 Toy Program public class public static main(string[] args) 9 10 main ( ) Toy Program public class public static main(string[] args) " " main ( ) customer2: "Rita Stein" 2

3 Toy Program public class public static main(string[] args) Account: number: 1234 Account: number: 2984 Account: number: 5678 " " "Rita Stein" main ( ) customer2: account1: account2: account3: Message Sequence Chart Message Sequence Chart public class public static main(string[] args) time main , account3 account1 account2 account3 balance: 900 number: transferto 300 balance: 200 number: 5678 withdraw 100 balance: 100 number: 2984 Output מנשקים public class public static main(string[] args) output: account1 has account2 has מנשק )interface( הוא מבנה תחבירי ב Java המאפשר לחסוך בקוד לקוח קוד אשר משתמש במנשק יוכל בזמן ריצה לעבוד עם מגוון מחלקות המממשות את המנשק הזה )ללא צורך בשכפול הקוד עבור כל מחלקה( דוגמא: נגן מוזיקה אשר מותאם לעבוד עם קובצי מוזיקה )mp3( ועם קובצי וידאו )mp4( 3

4 Playing Mp3 Playing VideoClips public class MP3Song public class Player public class VideoClip public class Player public play() private boolean repeat; public play() // same as before... // audio codec calculations, private boolean shuffle; // video codec calculations, // play the song... public playsongs(mp3song[] songs) do // play the clip... public playvideos(videoclip[] clips) do // does complicated stuff // does complicated stuff Collections.shuffle(Arrays.asList(clips)); // related to MP3 format... Collections.shuffle(Arrays.asList(songs)); // related to MP4 format... for (MP3Song song : songs) for (VideoClip videoclip : clips) videoclip.play(); song.play(); while (repeat); while (repeat); שימוש במנשק שכפול קוד public playsongs(mp3song[] songs) do Collections.shuffle(Arrays.asList(songs)); for (MP3Song song : songs) song.play(); while (repeat); למרות ששני השרותים נקראים play() אלו פונקציות שונות! public play (Playable[] items) do Collections.shuffle(Arrays.asList(items)); for (Playable item : items) item.play(); public playvideos(videoclip[] clips) do Collections.shuffle(Arrays.asList(clips)); for (VideoClip videoclip : clips) videoclip.play(); while (repeat); public interface Playable public play(); while (repeat); נרצה למזג את שני קטעי הקוד מימוש המנשק ע"י הספקים public class VideoClip implements public play() // render video, play the clip on screen... // does complicated stuff related to video formats... public class MP3Song implements public play() // audio codec calculations, play the song... // does complicated stuff related to MP3 format... מערכים פולימורפים Playable[] playables = new Playable[3]; playables[0] = new MP3Song(); playables[1] = new VideoClip(); playables[2] = new MP4Song(); // new Playable class Player player = new Player(); // init player... public play (Playable [] items) player.play(playables); עבור כל איבר במערך יקרא ה play() המתאים do Collections.shuffle(Arrays.asList(items)); for (Playable item : items) item.play(); while (repeat); 4

5 פעולות על סיביות - דוגמאות פעולות על סיביות אופרטורים לביצוע פעולות על ביטים רק על טיפוסים איטנגרליים char( )int, short, byte, ~ << >> >>> & ^ Unary bitwise complement Signed left shift Signed right shift Unsigned right shift Bitwise AND Bitwise XOR Bitwise OR 25 3 ~3-3 3 << 2-3 >> 1-3 >>> 1 ייצוג בינארי int 32 ביטים מה נקבל מ & 3?i שני הביטים הימניים של i ומה נקבל מ?i & 0xF0 26 5

תוכנה 1 * לא בהכרח בסדר הזה

תוכנה 1 * לא בהכרח בסדר הזה תוכנה 1 תרגול 7: מנשקים, פולימורפיזם ועוד * לא בהכרח בסדר הזה 2 מנשקים מנשקים מנשק )interface( הוא מבנה תחבירי ב- Java המאפשר לחסוך בקוד לקוח. מנשק מכיל כותרות של מתודות המימוש שלהן. )חתימות( ללא קוד אשר

More information

תוכנה 1 * לא בהכרח בסדר הזה

תוכנה 1 * לא בהכרח בסדר הזה תוכנה 1 תרגול 7: מנשקים, פולימורפיזם ועוד * לא בהכרח בסדר הזה 2 מנשקים מנשקים מנשק )interface( הוא מבנה תחבירי ב- Java המאפשר לחסוך בקוד לקוח. מנשק מכיל כותרות של מתודות המימוש שלהן. )חתימות( ללא קוד אשר

More information

תוכנה 1 * לא בהכרח בסדר הזה

תוכנה 1 * לא בהכרח בסדר הזה תוכנה 1 תרגול 7: מנשקים, פולימורפיזם ועוד * לא בהכרח בסדר הזה 2 מנשקים מנשקים - תזכורת מנשק )interface( הוא מבנה תחבירי ב- Java המאפשר לחסוך בקוד לקוח. מנשק מכיל כותרות של מתודות )חתימות(. מימוש דיפולטיבי

More information

מבוא למדעי המחשב תרגול 8 רשימה משורשרת כללית, Comparator

מבוא למדעי המחשב תרגול 8 רשימה משורשרת כללית, Comparator מבוא למדעי המחשב 2017 תרגול 8 רשימה משורשרת כללית, Comparator בתרגול היום. LinkedList בניית ההכללה מ- LinkIntList תרגול המבנה ושימושיו ממשקים: Comparator Sorted Linked List ל- LinkedList ע"י שימוש ב- Comparator

More information

תוכנה 1. תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes

תוכנה 1. תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes תוכנה 1 תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes class Outer { static class NestedButNotInner {... class Inner {... מחלקות מקוננות NESTED CLASSES 2 מחלקה מקוננת Class) )Nested

More information

הנכות 1 םוכיס לוגרת 14 1

הנכות 1 םוכיס לוגרת 14 1 תוכנה 1 סיכום תרגול 14 1 קצת על מנשקים מנשק יכול להרחיב יותר ממנשק אחד שירותים במנשק הם תמיד מופשטים וציבוריים public interface MyInterface { public abstract int foo1(int i); int foo2(int i); The modifiers

More information

הנכות 1 תואיגש םע תודדומתהו תואלול,םי : כרעמ 2 לוגרת

הנכות 1 תואיגש םע תודדומתהו תואלול,םי : כרעמ 2 לוגרת תוכנה 1 תרגול 2: מערכים, לולאות והתמודדות עם שגיאות מערכים מערכים Array: A fixed-length data structure for storing multiple values of the same type Example from last week: An array of odd numbers: Indices

More information

הנכות 1 תואיגש םע תודדומתהו תואלול,םיכרעמ : לו 2 גרת

הנכות 1 תואיגש םע תודדומתהו תואלול,םיכרעמ : לו 2 גרת תוכנה 1 תרגול 2: מערכים, לולאות והתמודדות עם שגיאות מערכים Array: A fixed-length data structure for storing multiple values of the same type Example from last week: An array of odd numbers: Indices (start

More information

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions מבוא לתיכנות עם MATLAB 234127 Lecture 5: Boolean logic and Boolean expressions Written by Prof. Reuven Bar-Yehuda, Technion 2013 Based on slides of Dr. Eran Eden, Weizmann 2008 1 >>g = [89 91 80 98]; >>p

More information

תוכנה 1 תרגול 2: מערכים ומבני בקרה

תוכנה 1 תרגול 2: מערכים ומבני בקרה תוכנה 1 תרגול 2: מערכים ומבני בקרה 2 Useful Eclipse Shortcuts Ctrl+1 quick fix for errors, or small refactoring suggestions Ctrl+SPACE code content assist (auto-completion) Auto completion for main create

More information

תוכנה 1 תרגול 2: מערכים, מבני בקרה ושגיאות

תוכנה 1 תרגול 2: מערכים, מבני בקרה ושגיאות תוכנה 1 תרגול 2: מערכים, מבני בקרה ושגיאות מערכים Array: A fixed-length data structure for storing multiple values of the same type Example: An array of odd numbers: Indices (start from 0) 0 1 2 3 4 5

More information

תוכנה 1 מערכים. Array Creation and Initialization. Array Declaration. Array Creation and Initialization. Loop through Arrays

תוכנה 1 מערכים. Array Creation and Initialization. Array Declaration. Array Creation and Initialization. Loop through Arrays מערכים Array: A fixed-length data structure for storing multiple values of the same type תוכנה 1 Example: An array of odd numbers: Indices (start from 0) 0 1 2 3 4 5 6 7 odds: 1 3 5 7 9 11 13 15 odds.length

More information

תוכנה 1 3 תרגול מס' מערכים ומבני בקרה

תוכנה 1 3 תרגול מס' מערכים ומבני בקרה תוכנה 1 3 תרגול מס' מערכים ומבני בקרה מערכים Array: A fixed-length data structure for storing multiple values of the same type Example: An array of odd numbers: Indices (start from 0) 0 1 2 3 4 5 6 7 odds:

More information

תור שימושים בעולם התוכנה

תור שימושים בעולם התוכנה מבוא למדעי המחשב הרצאה : Queue, Iterator & Iterable תור מבנה נתונים אבסטרקטי תור שימושים בעולם התוכנה השימושים של תורים בעולם התוכנה מזכירים מאוד תורים במציאות: )VoIP( )YouTube( מקלדת שידור סרט באינטרנט

More information

תוכנה 1 מערכים. Array Creation and Initialization. Array Declaration. Loop through Arrays. Array Creation and Initialization

תוכנה 1 מערכים. Array Creation and Initialization. Array Declaration. Loop through Arrays. Array Creation and Initialization מערכים תוכנה 1 Array: A fixed-length data structure for storing multiple values of the same type Example from last week: An array of odd numbers: Indices (start from 0) 0 1 2 3 4 5 6 7 תרגול 2: מערכים

More information

משתנים שעור מס. 2 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1

משתנים שעור מס. 2 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1 משתנים שעור מס. 2 דרור טובי דר' כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1 תפקיד המשתנים הצהרה על משתנה השמת ערך במשתנה int a, b, c; a = 1234; b = 99; c = a + b; משתנים מאפשרים לנו לשמור

More information

הנכות 1 םוכיס לוגרת 13 1

הנכות 1 םוכיס לוגרת 13 1 תוכנה 1 סיכום תרגול 13 1 קצת על מנשקים מנשק יכול להרחיב יותר ממנשק אחד שירותים במנשק הם תמיד מופשטים וציבוריים public interface MyInterface { public abstract int foo1(int i); int foo2(int i); The modifiers

More information

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions מבוא לתיכנות עם MATLAB 23427 Lecture 5: Boolean logic and Boolean expressions Written by Prof. Reuven Bar-Yehuda, Technion 203 Based on slides of Dr. Eran Eden, Weizmann 2008 ביטויים לוגיים דוגמא: תקינות

More information

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions מבוא לתיכנות עם MATLAB 234127 Lecture 5: Boolean logic and Boolean expressions Written by Prof. Reuven Bar-Yehuda, Technion 2013 Based on slides of Dr. Eran Eden, Weizmann 2008 1 motivation Proper academic

More information

הנכות 1 םוכיס לוגרת 13 1

הנכות 1 םוכיס לוגרת 13 1 תוכנה 1 סיכום תרגול 13 1 בחינה באופק! הבחינה תכלול את כל הנושאים שכיסינו במהלך הסמסטר: כל ההרצאות כל תרגולים כל תרגילי בית חומר סגור שאלות אמריקאיות 2 קצת על מנשקים מנשק יכול להרחיב שירותים במנשק הם תמיד

More information

תזכורת: עץבינארי מבוא למדעי המחשב הרצאה 24: עצי חיפוש בינאריים

תזכורת: עץבינארי מבוא למדעי המחשב הרצאה 24: עצי חיפוש בינאריים מבוא למדעי המחשב הרצאה 2: עצי חיפוש בינאריים תזכורת: עץבינארי בנוסףלרשימהמקושרת ומערך, הצגנומבנהנתונים קונקרטיחדש עץבינארי עץבינארימורכבמ: שורש תת-עץשמאלי תת-עץימני A B C D E F G 2 תזכורת: שורש ותתי-עצים

More information

תרגול 3 מערכים ופונקציות

תרגול 3 מערכים ופונקציות מבוא למדעי המחשב 2017 תרגול 3 מערכים ופונקציות מערכים מאפשרים עבודה עם מקבצים של נתונים פונקציות מאפשרות אבסטרקציה והאחדה של הקוד ראינו בהרצאה מערכים הצהרה, אתחול, גישה לאיברים במערך יצוג בזיכרון ובטבלת

More information

JAVA OPERATORS GENERAL

JAVA OPERATORS GENERAL JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators

More information

תוכנה 1 בשפת Java תרגול מספר 9: הורשה רובי בוים ומתי שמרת בית הספר למדעי המחשב אוניברסיטת תל אביב

תוכנה 1 בשפת Java תרגול מספר 9: הורשה רובי בוים ומתי שמרת בית הספר למדעי המחשב אוניברסיטת תל אביב תרגול מספר 9: הורשה רובי בוים ומתי שמרת בית הספר למדעי המחשב ירושה ממחלקות קיימות ראינו בהרצאה שתי דרכים לשימוש חוזר בקוד של מחלקה קיימת: הכלה + האצלה ירושה המחלקה היורשת יכולה להוסיף פונקציונליות שלא

More information

תכנות מונחה עצמים משחקים תשע"ו

תכנות מונחה עצמים משחקים תשעו move semantics 1 תכנות מונחה עצמים ופיתוח משחקים תשע"ו סמנטיקת ההעברה semantics( )Move move semantics 2 מטרה האצה של התוכניות, שיפור בביצועים על ידי חסכון בבנייה והעתקה של אובייקטים זמניים move semantics

More information

Simple Web Service. namespace MyService { public class Service1 : System.Web.Services.WebService {

Simple Web Service. namespace MyService { public class Service1 : System.Web.Services.WebService { Simple Web Service WS פתיחת פרוייקט File New Project ASP.Net web service project - >http://localhost/webservice1 יצירת שירות המחשב חיבור וחילוק 2 מספרים : הטיפוסים הבסיסיים using System; איסוף וניהוף אוספי

More information

תוכנה 1. תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes בית הספר למדעי המחשב אוניברסיטת תל אביב

תוכנה 1. תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes בית הספר למדעי המחשב אוניברסיטת תל אביב תוכנה 1 תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes בית הספר למדעי המחשב אוניברסיטת תל אביב 1 2 STATIC VS. DYNAMIC BINDING 3 Static versus Dynamic Binding public class Account

More information

מחרוזות ב Java ותכנות מונחה בדיקות )Test Driven Development(

מחרוזות ב Java ותכנות מונחה בדיקות )Test Driven Development( מחרוזות ב Java ותכנות מונחה בדיקות )Test Driven Development( תוכנה 1 תרגול 8 String Immutability Strings are constants String s = " Tea "; s = s.trim(); s = s.replace('t', 'S'); s 1 2 3 " Tea " "Tea" "Sea"

More information

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Basic Operators Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators

More information

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators JAVA Standard Edition Java - Basic Operators Java provides a rich set of operators to manipulate variables.

More information

BankAccount account1 = new BankAccount(...);,this

BankAccount account1 = new BankAccount(...);,this 1 6 ',, : (.new ) BankAccount account1 = new BankAccount(...); פ, פ,this,, ) \ פ\( פ פ פ 2 ) ( " פ : :? public class BankAccount {... private double balance;... 3 :),, ( 3 )queries, accessors( ), ( :)observers(

More information

תוכנה 1 בשפת Java נושאים שונים בהורשה רובי בוים ומתי שמרת בית הספר למדעי המחשב אוניברסיטת תל אביב

תוכנה 1 בשפת Java נושאים שונים בהורשה רובי בוים ומתי שמרת בית הספר למדעי המחשב אוניברסיטת תל אביב תוכנה 1 בשפת Java נושאים שונים בהורשה רובי בוים ומתי שמרת בית הספר למדעי המחשב אוניברסיטת תל אביב Today Static vs. Dynamic binding Equals / hashcode String Immutability (maybe) 2 Static versus run-time

More information

Practical Session No. 14 Topological sort,amortized Analysis

Practical Session No. 14 Topological sort,amortized Analysis Practical Session No. 14 Topological sort,amortized Analysis Topological- Sort Topological sort Ordering of vertices in a directed acyclic graph (DAG) G=(V,E) such that if there is a path from v to u in

More information

תוכנה 1 תרגול מספר 13

תוכנה 1 תרגול מספר 13 1 תוכנה 1 תרגול מספר 13 ו- HashCode Equals עוד על טיפוסים מוכללים )Advanced Generics( חריגים )Exceptions( בית הספר למדעי המחשב אוניברסיטת תל אביב 1 2 ו- HASHCODE EQUALS 3 תזכורת: המחלקה Object package

More information

תוכנה 1 תרגול מספר 13

תוכנה 1 תרגול מספר 13 1 2 תוכנה 1 תרגול מספר 13 ו- HashCode Equals עוד על טיפוסים מוכללים )Advanced Generics( ו- HASHCODE EQUALS חריגים )Exceptions( בית הספר למדעי המחשב אוניברסיטת תל אביב 1 3 4 package java.lang; תזכורת: המחלקה

More information

ב ה צ ל ח ה! אוניברסיטת בן גוריון בנגב מספר נבחן : תאריך המבחן: כ"ה תשרי תשע"ח 15/10/17 שמות המורים: ציון סיקסיק מיועד לתלמידי : א'

ב ה צ ל ח ה! אוניברסיטת בן גוריון בנגב מספר נבחן : תאריך המבחן: כה תשרי תשעח 15/10/17 שמות המורים: ציון סיקסיק מיועד לתלמידי : א' אוניברסיטת בן גוריון בנגב מספר נבחן : תאריך המבחן: כ"ה תשרי תשע"ח 15/10/17 שמות המורים: ציון סיקסיק א' ב- C תכנות מבחן ב: 202-1-9011 מס' הקורס : הנדסה מיועד לתלמידי : א' מועד קיץ סמ' שנה תשע"ז 3 שעות משך

More information

גיליון תשובות מספר נבחן: סעיף ג (10 נקודות) הגדרת בטיחות הינה שמירה על האינווריאנטה של האובייקטים במהלך ההרצה.

גיליון תשובות מספר נבחן: סעיף ג (10 נקודות) הגדרת בטיחות הינה שמירה על האינווריאנטה של האובייקטים במהלך ההרצה. גיליון תשובות מספר נבחן: (30 נקודות) שאלה 1 סעיף א (15 נקודות) remove() המתודה remove() גם משנה את מצב האובייקט,(command) וגם מחזירה ערך.(query) על פי עקרונות העיצוב שלמדנו בכיתה יש להפריד שאילתות מפקודות.

More information

בית הספר למדעי המחשב אוניברסיטת תל אביב תוכנה 1 תרגול מספר 9: הורשה מחלקות אבסטרקטיות חריגים

בית הספר למדעי המחשב אוניברסיטת תל אביב תוכנה 1 תרגול מספר 9: הורשה מחלקות אבסטרקטיות חריגים בית הספר למדעי המחשב אוניברסיטת תל אביב תוכנה 1 תרגול מספר 9: הורשה מחלקות אבסטרקטיות חריגים 2 ירושה ממחלקות קיימות ראינו בהרצאה שתי דרכים לשימוש חוזר בקוד של מחלקה קיימת: הכלה + האצלה הכלה )aggregation(

More information

תוכנה 1 ומחלקות פנימיות

תוכנה 1 ומחלקות פנימיות תוכנה 1 Design Patterns ומחלקות פנימיות תרגול 11: 1 Design Patterns A general reusable solution to recurring design problems. Not a recipe A higher level language for design Factory, Singleton, Observer

More information

הנכות 1 םוכיס לוגרת 13 1

הנכות 1 םוכיס לוגרת 13 1 תוכנה 1 סיכום תרגול 13 1 בחינה באופק! הבחינה תכלול את כל הנושאים שכיסינו במהלך הסמסטר: כל ההרצאות כל תרגולים כל תרגילי בית חומר סגור שאלות אמריקאיות 2 קצת על מנשקים מנשק יכול להרחיב יותר ממנשק אחד שירותים

More information

מערכים שעור מס. 4 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1

מערכים שעור מס. 4 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1 מערכים שעור מס. 4 דרור טובי דר' כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1 למה מערכים? ברצוננו לאחסן בתוכנית ציוני בחינה כדי לחשב את ממוצע הציונים וסטיית התקן. נניח ש 30 סטודנטים לקחו

More information

תרגול מספר 3: מערכים

תרגול מספר 3: מערכים היום בתרגול:.1.2 תרגול מספר 3: מערכים מערך חד-מימדי: מה זה מערך ולמה צריך אותו? איך מגדירים? איך זה נראה בזכרון? דוגמאות לשימוש במערך חד-מימדי השוואה בין משתנה פרימיטיבי למשתנה שאינו פרימיטיבי מערך דו-מימדי:

More information

סכום (סדרת ערכים) אחרת - דוגמא: סכום-ספרות (num) אם < 10 num החזר 1 או אם = 0 = num החזר 0 public static int numofdigits (int num)

סכום (סדרת ערכים) אחרת - דוגמא: סכום-ספרות (num) אם < 10 num החזר 1 או אם = 0 = num החזר 0 public static int numofdigits (int num) 1 תבנית צבירה תבניות אלגוריתמיות לפעולות רקורסיביות תבנית צבירה לסדרת ערכים: סכום (סדרת ערכים) החזר את ערך הקצה + סכום (סדרת הערכים ללא ערך הקצה) דוגמא: פעולה המחזירה את סכום הספרות שבמספר שלם לא שלילי

More information

מבוא לתכנות ב- JAVA תרגול 7

מבוא לתכנות ב- JAVA תרגול 7 מבוא לתכנות ב- JAVA תרגול 7 רקורסיה - הקדמה הגדרה רקורסיבית: חדר הוא מסודר אם צד שמאל שלו מסודר שלו מסודר. וצד ימין שיטת פתרון רקורסיבית: פתרון מופעים פשוטים יותר של בעיה בכדי לפתור את הבעיה המקורית רקורסיה

More information

היצביט ומ - ןוכית ת וי נבת

היצביט ומ - ןוכית ת וי נבת תבני ו ת תיכון Patterns) (Design תבנ יו ת תיכון - מו טיבציה בחיי היום יום אנחנו מתארים דברים תוך שימוש בתבניות חוזרות: "מכונית א' היא כמו מכונית ב', אבל יש לה 2 דלתות במקום 4" "אני רוצה ארון כמו זה, אבל

More information

גיליון תשובות מספר נבחן:

גיליון תשובות מספר נבחן: גיליון תשובות מספר נבחן: 03( שאלה 1 סעיף א )02 (i) //@PRE: checkinv(other.getx(),other.gety(),other.getradius()) //@POST: getradius() other.getradius() >= // Math.max(Math.abs(getY()-other.getY()),Math.abs(getX()-

More information

תרגול 3 מערכים ופונקציות

תרגול 3 מערכים ופונקציות מבוא למדעי המחשב 2018 תרגול 3 מערכים ופונקציות מערכים מאפשרים עבודה עם מקבצים של נתונים פונקציות מאפשרות אבסטרקציה והאחדה של הקוד ראינו בהרצאה מערכים הצהרה, אתחול, גישה לאיברים במערך יצוג בזיכרון ובטבלת

More information

מבוא לתכנות ב- JAVA מעבדה 4

מבוא לתכנות ב- JAVA מעבדה 4 מבוא לתכנות ב- JAVA מעבדה 4 מה בתרגול מערכים מחרוזות מערך חד מימדי מערך הוא מבנה המחזיק סדרה של איברים מאותו טיפוס גודל המערך הוא קבוע )נקבע בעת יצירת המערך( הגישה לכל איבר היא באמצעות אינדקס למה לי מערך?

More information

public class Account { private int id; private static int nextaccountid = 0; private String name; private double balance;

public class Account { private int id; private static int nextaccountid = 0; private String name; private double balance; public class Account { private int id; private static int nextaccountid = 0; private String name; private double balance; public double deposit(double amount) { public double withdraw(double amount) {

More information

ת ונכת סרוק תורשוקמ תומישר :יעישת רועיש 1

ת ונכת סרוק תורשוקמ תומישר :יעישת רועיש 1 קורס תכנות שיעור תשיעי: רשימות מקושרות 1 הקצאה דינאמית של מערכים דו-ממדיים )לפחות( שלוש גישות אפשריות:.1 מערך של מערכים מצביעים לתוך מערך "גדול".2 3. מצביע יחיד למערך גדול 2 The Interface 3 (Simple) Usage

More information

Practice problem on defining and using Class types. Part 4.

Practice problem on defining and using Class types. Part 4. CS180 Programming Fundamentals Practice problem on defining and using Class types. Part 4. Implementing object associations: Applications typically consist of collections of objects of different related

More information

9. טופס הזמנת מוצרים טופס ההזמנה הוא טופס מורכב. מעורבים בו 4 טבלאות נתונים. קשרי הגומלין בין הטבלאות : הטופס :

9. טופס הזמנת מוצרים טופס ההזמנה הוא טופס מורכב. מעורבים בו 4 טבלאות נתונים. קשרי הגומלין בין הטבלאות : הטופס : 9. טופס הזמנת מוצרים טופס ההזמנה הוא טופס מורכב. מעורבים בו 4 טבלאות נתונים. קשרי הגומלין בין הטבלאות : הטופס : 1 בהרצה : הוספת פריט רשימת פריטים ההכנה לעבודה : 1. להוסיף שתי טבלאות למאגר טבלת orders וטבלת.orderDetail

More information

מצליחה. 1. int fork-bomb() 2. { 3. fork(); 4. fork() && fork() fork(); 5. fork(); printf("bla\n"); 8. return 0; 9. }

מצליחה. 1. int fork-bomb() 2. { 3. fork(); 4. fork() && fork() fork(); 5. fork(); printf(bla\n); 8. return 0; 9. } שאלה : (4 נקודות) א. ב. ג. (5 נקודות) הגדירו את המונח race-condition במדוייק לא להשמיט פרטים. ספקו דוגמא. (5 נקודות) מהו? Monitor נא לספק הגדרה מלאה. ( נקודות) ( נקודות) ציינו כמה תהליכים יווצרו בקוד הבא

More information

Object-Oriented Programming. Topic 2: Fundamental Programming Structures in Java

Object-Oriented Programming. Topic 2: Fundamental Programming Structures in Java Electrical and Computer Engineering Object-Oriented Topic 2: Fundamental Structures in Java Maj Joel Young Joel.Young@afit.edu 8-Sep-03 Maj Joel Young Java Identifiers Identifiers Used to name local variables

More information

Expressions & Flow Control

Expressions & Flow Control Objectives Distinguish between instance and local variables 4 Expressions & Flow Control Describe how instance variables are initialized Identify and correct a Possible reference before assignment compiler

More information

Amortized Analysis, Union-Find,

Amortized Analysis, Union-Find, Practical Session No. 13 Amortized Analysis, Union-Find, AMORTIZED ANALYSIS Refers to finding the average running time per operation, over a worst-case sequence of operations. Amortized analysis differs

More information

שיעור מספר 3: "מחלקות וטיפוסים"

שיעור מספר 3: מחלקות וטיפוסים שיעור מספר 3: "מחלקות וטיפוסים" בית הספר למדעי המחשב על סדר היום מודל הזיכרון של Java Heap and Stack העברת ארגומנטים מנגנוני שפת Java עצמים ושירותי מופע 2 העברת ארגומנטים כאשר מתבצעת קריאה לשרות, ערכי

More information

The single cycle CPU

The single cycle CPU The single cycle CPU [2 0] Shift Jump address [31 0] left 2 26 28 0 1 Add + [31 28] [31 26] Control RegDst Jump Branch MemRead MemtoReg Op MemWrite Src RegWrite Shift left 2 Add result M u x 1 0 M u x

More information

קורס תכנות רשימה מקושרת דוגמה: חיפוש מעבר על רשימה דוגמא: שחרור רשימה מקושרת דוגמא: הוספת אברים שלא בהתחלה

קורס תכנות רשימה מקושרת דוגמה: חיפוש מעבר על רשימה דוגמא: שחרור רשימה מקושרת דוגמא: הוספת אברים שלא בהתחלה רשימה מקושרת רשימה היא אוסף סדור של ערכים פעולות רשימה לעומת מערך קורס תכנות שיעור עשירי: מיונים, חיפושים, קצת ניתוח זמני ריצה, קצת תיקון טעויות ועוד על רשימות 3 5 7 9 typedef struct node int data; struct

More information

שיעור מספר 8: "אמא יש רק אחת" )הורשה I(

שיעור מספר 8: אמא יש רק אחת )הורשה I( שיעור מספר 8: "אמא יש רק אחת" )הורשה I( שחר מעוז בית הספר למדעי המחשב על סדר היום יחסים בין מחלקות ירושה כיחס is-a טיפוס סטטי וטיפוס דינמי המחלקה Object מחלקות מופשטות 2 מלבן צבעוני נרצה לבנות מחלקה המייצגת

More information

שאלה 1 מהו הפלט של התוכנית הבאה:

שאלה 1 מהו הפלט של התוכנית הבאה: תרגול חזרה שאלה 1 מהו הפלט של התוכנית הבאה: public sttic int wht(int n) { int i; int sum=0; if(n == 0) return 1; for (i=0; i

More information

The Java language has a wide variety of modifiers, including the following:

The Java language has a wide variety of modifiers, including the following: PART 5 5. Modifier Types The Java language has a wide variety of modifiers, including the following: Java Access Modifiers Non Access Modifiers 5.1 Access Control Modifiers Java provides a number of access

More information

קורס תכנות שיעור שני: שימוש במשתנים,

קורס תכנות שיעור שני: שימוש במשתנים, קורס תכנות שיעור שני: שימוש במשתנים, בקרת זרימה, לולאות 1 נושאי השיעור היום משתנים )variables( טיפוסי משתנים בשפת C הגדרת משתנים השמה למשתנים פעולות על משתנים קליטת ערכים מהמשתמש הדפסה משתנים בקרת זרימה

More information

תוכנה 1 טיפוסי השפה טיפוסים לא פרימיטיביים הטיפוסים הפרימיטיביים מחרוזות המרה למספרים תרגול 2: טיפוסי שפה, מחרוזות, מערכים ושגיאות

תוכנה 1 טיפוסי השפה טיפוסים לא פרימיטיביים הטיפוסים הפרימיטיביים מחרוזות המרה למספרים תרגול 2: טיפוסי שפה, מחרוזות, מערכים ושגיאות טיפוסי השפה תוכנה 1 תרגול 2: טיפוסי שפה, מחרוזות, מערכים ושגיאות טיפוסים יסודיים (פרימיטיביים): 8 טיפוסים מוגדרים בשפה שמיועדים להכיל ערכים פשוטים: מספרים שלמים: byte, short, int, long מספרים ממשיים: float,

More information

תרשים המחלקות ותרשים העצמים

תרשים המחלקות ותרשים העצמים 1 תרשים המחלקות ותרשים העצמים חלק שלישי: ניתוח ועיצוב מערכות מידע באמצעות שימוש ב- UML ומתודולוגיית ה- Process )UP( Unified E1 3 E2 2 Outline UML Introduction Class Diagram Class Association Self association

More information

הוראות חיבור e-port בפרוטוקול Art-Net למערכות תאורה שונות

הוראות חיבור e-port בפרוטוקול Art-Net למערכות תאורה שונות 30.06.2014 הוראות חיבור e-port בפרוטוקול Art-Net למערכות תאורה שונות המסמך נכתב ונערך ע"י רונן בן-הרוש עבור חברת דנאור מערכות תיאטרון ואולפנים בע"מ. http://www.danor.com הבדיקות נעשו באולם רובינא, בתיאטרון

More information

נתונות שתי המחלקות הבאות:

נתונות שתי המחלקות הבאות: ממבחנים שאלות מבנה הנתונים תור (queue) הוא מבנה הדומה למחסנית (stack) שנלמדה בקורס. לתור ניתן להוסיף איברים (ע"י פעולה הנקראת (enqueue וניתן להסיר את האיבר שבראש התור,(dequeue) כלומר האיבר הוותיק ביותר

More information

תרגול מס' 5: IO )קלט-פלט(

תרגול מס' 5: IO )קלט-פלט( תוכנה 1 אוניברסיטת תל אביב תרגול מס' 5: IO )קלט-פלט( זרמי קלט וזרמי פלט Streams(,(Input & Output קוראים וכותבים, והשימוש בהם לצורך עבודה עם קבצים 2 Input/Output in Java פעולות קלט-פלט הן רכיב מרכזי בכל

More information

תרגול 6 רקורסיה ותכנות מונחה עצמים

תרגול 6 רקורסיה ותכנות מונחה עצמים מבוא למדעי המחשב 2017 תרגול 6 רקורסיה ותכנות מונחה עצמים מבוא למדעי המחשב 1 ראינו בהרצאה רקורסיה תכנות מונחה עצמים: מחלקה ואובייקט שדות, בנאים ושיטות מימוש מערך דינאמי של ראשוניים בתרגול היום רקורסיה הדפסת

More information

הקלחמ ה תמרב ת ונ וכ ת (static members ) יליזרב דהוא Java תפשב ם דקת מ תונכת ביבא ל ת תטיסרבינוא

הקלחמ ה תמרב ת ונ וכ ת (static members ) יליזרב דהוא Java תפשב ם דקת מ תונכת ביבא ל ת תטיסרבינוא ת כו נו ת ברמת ה מחלקה (static members) אוהד ברזילי תכנות מ תקד ם בשפת Java אוניברסיטת ת ל אביב static keyword שדות המוגדרים כ static מציינים כי הם מוגדרים ברמת המחלקה ולא ברמת עצם כל העצמים של אותה מחלקה

More information

Practical Session - Heap

Practical Session - Heap Practical Session - Heap Heap Heap Maximum-Heap Minimum-Heap Heap-Array A binary heap can be considered as a complete binary tree, (the last level is full from the left to a certain point). For each node

More information

C02: Overview of Software Development and Java

C02: Overview of Software Development and Java CISC 3120 C02: Overview of Software Development and Java Hui Chen Department of Computer & Information Science CUNY Brooklyn College 08/31/2017 CUNY Brooklyn College 1 Outline Recap and issues Brief introduction

More information

CT 229. Java Syntax 26/09/2006 CT229

CT 229. Java Syntax 26/09/2006 CT229 CT 229 Java Syntax 26/09/2006 CT229 Lab Assignments Assignment Due Date: Oct 1 st Before submission make sure that the name of each.java file matches the name given in the assignment sheet!!!! Remember:

More information

Handout 8 Classes and Objects Continued: Static Variables and Constants.

Handout 8 Classes and Objects Continued: Static Variables and Constants. Handout 8 CS603 Object-Oriented Programming Fall 16 Page 1 of 8 Handout 8 Classes and Objects Continued: Static Variables and Constants. 1. Static variable Declared with keyword static One per class (instead

More information

Programming for Engineers in Python

Programming for Engineers in Python Programming for Engineers in Python Lecture 9: Sorting, Searching and Time Complexity Analysis Autumn 2011-12 1 Lecture 8: Highlights Design a recursive algorithm by 1. Solving big instances using the

More information

Programming for Engineers in Python

Programming for Engineers in Python Programming for Engineers in Python Lecture 9: Sorting, Searching and Time Complexity Analysis Autumn 2011-12 1 Lecture 8: Highlights Design a recursive algorithm by 1. Solving big instances using the

More information

פיתוח מערכות תוכנה מבוססות Java אוהד ברזילי

פיתוח מערכות תוכנה מבוססות Java אוהד ברזילי מה בתוכנית? נדון בחלופות להשגת persistency בתוכנה: Relational DB and SQL JDBC persistence layer ORM Persistency...ומה קורה אם באמצע התוכנית יש הפסקת חשמל? על רוב התוכניות להיות מסוגלות לשמור מידע בין ריצות

More information

תרגול 12. Standard Template Library כתיבת אלגוריתמים גנריים מצביעים חכמים

תרגול 12. Standard Template Library כתיבת אלגוריתמים גנריים מצביעים חכמים תרגול 12 Standard Template Library כתיבת אלגוריתמים גנריים מצביעים חכמים ספרית התבניות הסטנדרטית קיימת בכל מימוש של ++C מכילה אוספים (Containers) ואלגוריתמים. משתמשת בתבניות :(templates) אוספי הנתונים

More information

LAB A Translating Data to Binary

LAB A Translating Data to Binary LAB A Translating Data to Binary Create a directory for this lab and perform in it the following groups of tasks: LabA1.java 1. Write the Java app LabA1 that takes an int via a command-line argument args[0]

More information

מבוא לתכנות מערכות מבחן מועד א' סמסטר חורף

מבוא לתכנות מערכות מבחן מועד א' סמסטר חורף הפקולטה למדעי המחשב פרופ' גיל ברקת נועם שגב, שרי דואק, רן ברואר, דור כהן הטכניון מכון טכנולוגי לישראל 70.70.07.4 מבוא לתכנות מערכות 024.00 מבחן מועד א' סמסטר חורף 07.207.4 הוראות כלליות משך המבחן: 081

More information

CS 11 java track: lecture 1

CS 11 java track: lecture 1 CS 11 java track: lecture 1 Administrivia need a CS cluster account http://www.cs.caltech.edu/ cgi-bin/sysadmin/account_request.cgi need to know UNIX www.its.caltech.edu/its/facilities/labsclusters/ unix/unixtutorial.shtml

More information

Introduction to Programming (Java) 2/12

Introduction to Programming (Java) 2/12 Introduction to Programming (Java) 2/12 Michal Krátký Department of Computer Science Technical University of Ostrava Introduction to Programming (Java) 2008/2009 c 2006 2008 Michal Krátký Introduction

More information

תכנות מתקדם בשפת C משתנים

תכנות מתקדם בשפת C משתנים תכנות מתקדם בשפת C משתנים 1 משתנים סוגי משתנים בשפת C ההבדלים בין סוגי המשתנים השונים 2 /* This program computes m to the power of n */ /* Assumptions: m is an integer; n is a positive integer */ #include

More information

A flow chart is a graphical or symbolic representation of a process.

A flow chart is a graphical or symbolic representation of a process. Q1. Define Algorithm with example? Answer:- A sequential solution of any program that written in human language, called algorithm. Algorithm is first step of the solution process, after the analysis of

More information

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators

More information

תוכנה 1 תרגול מספר 10: תרגיל חזרה חברת הייטק בית הספר למדעי המחשב אוניברסיטת תל אביב

תוכנה 1 תרגול מספר 10: תרגיל חזרה חברת הייטק בית הספר למדעי המחשב אוניברסיטת תל אביב 1 תוכנה 1 תרגול מספר 10: תרגיל חזרה חברת הייטק בית הספר למדעי המחשב אוניברסיטת תל אביב 1 2 חברת הייטק בתרגיל זה נתרגל מספר נושאים אותם למדנו בשיעורים האחרונים: עיצוב ובניית מודל המורכב ממחלקות לתיאור סביבה

More information

- מבחן. - 4 עבודות ב- JAVA. הגשה בזוגות דרך ה- System Submission

- מבחן. - 4 עבודות ב- JAVA. הגשה בזוגות דרך ה- System Submission 1 - מבחן. - 4 עבודות ב- JAVA 60% 40% הגשה בזוגות דרך ה- System Submission 2 UML Class Diagrams Packages Class Path JAR Files חלק ראשון: חלק שני: 3 An abstraction of software features A structure that singles

More information

ספרית התבניות הסטנדרטית (STL) כתיבת אלגוריתמים גנריים מצביעים חכמים. .vector. list iterator נכיר תחילה את האוסף הפשוט ביותר בספריה

ספרית התבניות הסטנדרטית (STL) כתיבת אלגוריתמים גנריים מצביעים חכמים. .vector. list iterator נכיר תחילה את האוסף הפשוט ביותר בספריה ספרית התבניות הסטנדרטית (STL) כתיבת אלגוריתמים גנריים מצביעים חכמים vector list iterator 2 קיימת בכל מימוש של ++C מכילה אוספים (Containers) ואלגוריתמים נכיר תחילה את האוסף הפשוט ביותר בספריה.vector מערך

More information

Outline for Today CSE 142. CSE142 Wi03 G-1. withdraw Method for BankAccount. Class Invariants

Outline for Today CSE 142. CSE142 Wi03 G-1. withdraw Method for BankAccount. Class Invariants CSE 142 Outline for Today Conditional statements if Boolean expressions Comparisons (=,!=, ==) Boolean operators (and, or, not - &&,,!) Class invariants Conditional Statements & Boolean Expressions

More information

ASP.Net Web API.

ASP.Net Web API. ASP.Net Web API 1 מה זה? Web API View בלבד ולא Data אותו מממש השרת והוא מחזיר לקליינט API הוא Web API הבקשה והתשובה הן בפרוטוקול Http\Https הקליינטים של Web API יכולים להיות רבים : אפשר להשתמש גם בMVC

More information

ASSIGNMENT 5 Objects, Files, and a Music Player

ASSIGNMENT 5 Objects, Files, and a Music Player ASSIGNMENT 5 Objects, Files, and a Music Player COMP-202A, Fall 2009, All Sections Due: Thursday, December 3, 2009 (23:55) You MUST do this assignment individually and, unless otherwise specified, you

More information

מבוא למדעי המחשב תירגול 3:

מבוא למדעי המחשב תירגול 3: מבוא למדעי המחשב תירגול 3: לולאות, קלט, וטיפוסים תוכנייה לולאת while קלט טיפוסי משתנים המרת טיפוסים טיפוס char מבוא למדעי המחשב מ' - תירגול 3 2 לולאת while מבוא למדעי המחשב מ' - תירגול 3 3 לולאת while

More information

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University Lecture 3 COMP1006/1406 (the Java course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments 1 (graded) & 2 3 (available now) & 4 (tomorrow) a quick look back primitive data types

More information

CS52 - Assignment 8. Due Friday 4/15 at 5:00pm.

CS52 - Assignment 8. Due Friday 4/15 at 5:00pm. CS52 - Assignment 8 Due Friday 4/15 at 5:00pm https://xkcd.com/859/ This assignment is about scanning, parsing, and evaluating. It is a sneak peak into how programming languages are designed, compiled,

More information

Engineering Programming A

Engineering Programming A Engineering Programming A תרגול 5 25.11.2012 מערכים חד-מימדיים )תזכורת( לדוגמא: מערך בשם Arr בגודל 8 שאיבריו מטיפוס int 3 7 5 6 8 1 23 16 0 1 2 3 4 5 6 7 ב - arr[0] ב יושב ערך שהוא המספר השלם 3 arr[1]

More information

מבוא לתכנות תוכנית שעור מס. 1 1 דר' דרור טובי, המרכז האוניברסיטאי אריאל בשומרון.

מבוא לתכנות תוכנית שעור מס. 1 1 דר' דרור טובי, המרכז האוניברסיטאי אריאל בשומרון. מבוא לתכנות תוכנית ראשונה שעור מס. 1 דרור טובי דר' 1 מבוא לתכנות בשפת ++C C \ שלום!! מרצה ד"ר דרור טובי, drorto@ariel.ac.il שעות קבלה: יום ב, 10-12 טלפון )אריאל( 03 9076547 אתר הקורס: http://www.ariel.ac.il/cs/pf/tdror/courses/cpp

More information

- MEAN Stack חזרה. MongoDB - as the database Express - as the web framework AngularJS - as the frontend framework NodeJS- as the server platform

- MEAN Stack חזרה. MongoDB - as the database Express - as the web framework AngularJS - as the frontend framework NodeJS- as the server platform הדר פיקאלי תשע"ו - 2016 - MEAN Stack חזרה בניית web applications כרוכה בשימוש בטכנולוגיות וכלים שונים, להתמודדות עם: מסד נתונים, פעולות בצד השרת, טיפול בצד הלקוח והצגה של הנתונים. מהו?MEAN "MEAN is a fullstack

More information

(A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

(A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution Ch 5 Arrays Multiple Choice 01. An array is a (A) (B) (C) (D) data structure with one, or more, elements of the same type. data structure with LIFO access. data structure, which allows transfer between

More information

רשימות דילוגים Skip Lists

רשימות דילוגים Skip Lists Lecture6 of Geiger & Itai s slide brochure www.cs.technion.ac.il/~dang/courseds רשימות דילוגים Skip Lists Skip lists: A probabilistic Alternative to Balanced Trees, William Pugh, Communications of the

More information